import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import index from '../views/index'
const nqm = ()=>import('../views/nqm/nqm')
// const UCB = ()=>import('./nqm')
// const lhb = ()=>import('@/views/lhb/index')
// import nqm from '../views/nqm/nqm'
import UCB from './nqm'
import lhb from '@/views/lhb/index'
const routes = [
  {
    path: '',
    redirect: '/home'
  },
  {
    path: '/home',
    component: index,
    name: 'indexPage',
    meta: {
      title: "河北大学计算机教学部 教学网站群"
    }
  },
  {
    path: '/nqm',
    component: nqm,
    meta: {
      title: "牛齐明的教学网站"
    }
  },
  UCB,
  {
    path: '/lhb',
    component: lhb,
    meta: {
      title: "林皓波的教学网站"
    }
  }
]
const router = new Router({
  routes,
  mode: 'history',
  base: '/hbucc/'
})

//前置钩子 (拦截器) hook
router.beforeEach(function (to, from, next) {
  if (to.matched.length > 0) {
    document.title = to.meta.title == null ? to.matched[0].meta.title : to.meta.title
  }
  next()
})

export default router